// components/index/infotable/index.js
import ddt from '../../../api/axios.js'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    shoplist: {
      type: Object,
      Array,
      value: '列表'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    shoplist:[],
  },
  created() {

  },
  /**
   * 组件的方法列表
   */
  methods: {
    add(){
      ddt('get', '/api/indexshops?page=' + 1).then(res => {
        this.setData({
          shoplist: res.data.data
        })
        // this.triggerEvent('addInfo')
        wx.setStorageSync('imgurl', res.data.data.url)
        
        console.log(res)
      })
    },
    chang(e){
      ddt('post','/api/collectshop',{
        shopid:e.currentTarget.dataset.id
      }).then(res=>{
        if(res.data.code ==1 ){
              wx.showToast({
                title: res.data.msg,
                icon:'none',
                duration:2000
              })  
        }else{
          wx.showToast({
            title: res.data.msg,
            icon:'error'
          })
        }
      })
    },
    gopath(e) {
      let id = e.currentTarget.dataset.id
      let sellmoney = e.currentTarget.dataset.sellmoney
      let title = this.data.shoplist.filter(item => item.id == id)[0].shopname
      console.log(title);
     
      wx.navigateTo({
        url: `/pages/orderfood/index?id=${id}&title=${title}&sellmoney=${sellmoney}`,
      })
      wx.setStorageSync('qisong', e.currentTarget.dataset.qi)
    },
  }
})